﻿using System;
using System.Runtime.InteropServices;
using DWORD = System.UInt32;
using WORD = System.UInt16;

namespace ZWFrameWork
{
    enum UNITY_PLATFORM
    {
        PLATFORM_OS_WINDOWS = 0x01,
        PLATFORM_OS_ANDROID = 0x11,
        PLATFORM_OS_IPHONE = 0x31,
        PLATFORM_OS_IPAD = 0x41,
    };

    enum ENCODE_PLATFORM
    {
        CLIENT_WINDOWS = 1, //WINDOWS
        CLIENT_COCOS = 2, //COCOS
        CLIENT_U3D = 3, //U3d
        CLIENT_H5 = 4 //H5
    }

    /// <summary>
    /// 网络相关配置
    /// </summary>
    public class NetConfig
    {
        // public const string LOGIN_SERVER_URL = "ws://192.168.31.234:6301"; //余前
        // public const string CHAT_SERVER_URL = "ws://192.168.31.234:6302";

        public const string LOGIN_SERVER_URL = "ws://15.207.99.251:6301";

        public const string CHAT_SERVER_URL = "ws://15.207.99.251:6302";
        // public readonly string GAME_SERVER_URL = "ws://15.207.99.251:6302";
    }


    [Serializable]
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
    public struct TCP_Validate
    {
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public byte[] szValidateKey;
    };


//网络命令
    [Serializable]
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
    public struct TCP_Command
    {
        public UInt16 wMainCmdID; //主命令码,2 bytes
        public UInt16 wSubCmdID; //子命令码,2 bytes
    };

//网络包头

    [Serializable]
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
    public struct TCP_Head
    {
        public TCP_Info TCPInfo; //基础结构
        public TCP_Command CommandInfo; //命令信息
    };

//网络内核
    [Serializable]
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)]
    public struct TCP_Info
    {
        public byte cbCheckCode; //效验字段,1 byte
        public byte cbDataKind; //数据类型,1 byte
        public UInt16 wPacketSize; //数据大小,2 bytes
    };
}